package main.java.com.extract.supers;

import main.java.com.extract.Employee;

import java.util.Enumeration;
import java.util.Vector;

/**
 * @description: 部门
 * @author: cong zhi
 * @createDate: 2022/6/14 7:55
 * @updateUser: cong zhi
 * @updateDate: 2022/6/14 7:55
 * @updateRemark: 修改内容
 * @version: v1.0
 */
public class Department extends Party {


    private Vector staff = new Vector();

    public Department(String name) {
        super(name);
    }


    public Enumeration getStaff() {
        return staff.elements();
    }

    public void setStaff(Vector staff) {
        this.staff = staff;
    }

    @Deprecated
    public int getTotalAnnualCost() {
        Enumeration e = getStaff();
        int result = 0;
        while (e.hasMoreElements()) {
            Employee each = (Employee) e.nextElement();
            result += each.getAnnualCost();
        }
        return result;
    }

    /**
     * 运用Rename Method将将名称改为相同
     *
     * @return
     */
    @Override
    public int getAnnualCost() {
        Enumeration e = getStaff();
        int result = 0;
        while (e.hasMoreElements()) {
            Employee each = (Employee) e.nextElement();
            result += each.getAnnualCost();
        }
        return result;
    }

    public int getHeadCount() {
        return staff.size();
    }

    public void addStaff(Employee arg) {
        staff.addElement(arg);
    }
}
